﻿<%@ Page Language="C#" MasterPageFile="~/GUIMaster.Master" AutoEventWireup="true"
    CodeBehind="travelSearch.aspx.cs" Inherits="GUI.travelSearch" meta:resourcekey="Page"
    Culture="Auto" UICulture="Auto" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script src="/common/geoCodingMenu/AAAGeoCodingMenu.js" type="text/javascript"></script>

    <script type="text/javascript">
        function bindCoords() {
            var departureTxt = document.getElementById("<%=txtStart.ClientID%>");
            var arriveTxt = document.getElementById("<%=txtFinish.ClientID%>");
            var departureCoords = document.getElementById("<%=latlongStart.ClientID%>");
            var arriveCoords = document.getElementById("<%=latlongFinish.ClientID%>");
            
            if (departureTxt.latitude && departureTxt.longitude && departureTxt.latitude != "-1" && departureTxt.longitude != "-1") {
                departureCoords.value = departureTxt.latitude + "," + departureTxt.longitude;
            } /*else if (departureCoords.defaultValue != "") {
                departureCoords.value = departureCoords.defaultValue;
            }*/ else {
                departureCoords.value = "";
            }
            
            if (arriveTxt.latitude && arriveTxt.longitude && arriveTxt.latitude != "-1" && arriveTxt.longitude != "-1") {
                arriveCoords.value = arriveTxt.latitude + "," + arriveTxt.longitude;
            } /*else if (arriveCoords.defaultValue != "") {
                arriveCoords.value = arriveCoords.defaultValue;
            }*/ else {
                arriveCoords.value = "";
            }
        }
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentHomePage" runat="server">

        <h1>
            <asp:Label ID="Label_Title" runat="server" meta:resourcekey="lblTitle1"></asp:Label>
           </h1>
        <div id="Search">
          <div id="Result">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                <asp:Panel ID="content" Visible="false" runat="server">
                <div id="header_content_result_trips"></div>
                <div class="line_content_result_trips">
                
                
                   
                <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                    <ProgressTemplate>
                    <div id="loader_friends">
                        <img alt="Loading please wait" src="../master/resourcesNew/img/loader.gif" />
                           <asp:Label ID="lbl_loader" runat="server" CssClass="lbl_strong" meta:resourcekey="lbl_loader"></asp:Label></div>
                        </ProgressTemplate>
                    
                </asp:UpdateProgress>
                    
                    <asp:GridView DataKeyNames="id, ReservationExpirationDate, Departure, Arrival, DepartureDate"
                        ID="gv_result" AllowPaging="true" AllowSorting="true" runat="server" 
                        BorderStyle="None" Width="750px"
                        GridLines="None" AutoGenerateColumns="false"
                        OnPageIndexChanging="PageChanged" 
                        onselectedindexchanged="gv_result_SelectedIndexChanged">
                        <PagerSettings Mode="Numeric" />
                        <PagerStyle HorizontalAlign="Center" />
                        <EmptyDataTemplate><asp:Label ID="lbl_noresult" runat="server" CssClass="lbl_strong" meta:resourcekey="lbl_NoResult"></asp:Label></EmptyDataTemplate>
                        <Columns>
                            <asp:TemplateField>
                                <ItemStyle CssClass="contentCreatedTripTable" Width="22px"></ItemStyle>
                                <ItemTemplate>
                                    <asp:Image ID="igmUser" runat="server" ImageUrl='<%#"master/resourcesNew/img/trip_" + tripExpired("" + Eval("ReservationExpirationDate"), "" + Eval("DepartureDate")) + "_expired.png" %>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderStyle-CssClass="headerCreatedTripTable" meta:resourcekey="lblDep"
                                ItemStyle-CssClass="Item_table_departure">
                                <ItemTemplate>
                                    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "passengerTripDetail.aspx?Trip=" +  Eval("id") %>'><%# Eval("Departure")%></asp:HyperLink>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderStyle-CssClass="headerCreatedTripTable" meta:resourcekey="lblArr"
                                ItemStyle-Width="30%">
                                <ItemTemplate>
                                    <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# "passengerTripDetail.aspx?Trip=" +  Eval("id") %>'><%# Eval("Arrival")%></asp:HyperLink>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="DepartureDate" HeaderStyle-CssClass="headerCreatedTripTable"
                                ItemStyle-CssClass="contentCreatedTripTable" ItemStyle-Width="20%" meta:resourcekey="lblDateDep"
                                SortExpression="DepartureDate">
                            </asp:BoundField>
                            <asp:BoundField DataField="EstimatedTime" HeaderStyle-CssClass="headerCreatedTripTable"
                                ItemStyle-CssClass="contentCreatedTripTable" ItemStyle-Width="10%" meta:resourcekey="lblEstimatedTime"
                                SortExpression="EstimatedTime">
                                <HeaderStyle CssClass="headerCreatedTripTable"></HeaderStyle>
                                <ItemStyle CssClass="contentCreatedTripTable"></ItemStyle>
                            </asp:BoundField>
                            <asp:BoundField DataField="EstimatedBudget" HeaderStyle-CssClass="headerCreatedTripTable"
                                ItemStyle-CssClass="contentCreatedTripTable" ItemStyle-Width="10%" meta:resourcekey="lblEstimatedBudget"
                                SortExpression="EstimatedBudget">
                                <HeaderStyle CssClass="headerCreatedTripTable"></HeaderStyle>
                                <ItemStyle CssClass="contentCreatedTripTable"></ItemStyle>
                            </asp:BoundField>
                        </Columns>
                    </asp:GridView>
                    
                    </div> 
                    <div id="footer_content_result_trips"></div>
                    </asp:Panel>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
        
        
        
            <asp:Panel ID="PanelSearch" runat="server" DefaultButton="btnSearch">
               <div id="form_search">
                <br />
                    <asp:Table ID="Table1" runat="server" Width="600px">
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:Label ID="lblStart" runat="server" meta:resourcekey="lblStart" CssClass="lbl_strong"></asp:Label>
                            </asp:TableCell>
                            <asp:TableCell>
                                <asp:TextBox ID="txtStart" runat="server" meta:resourcekey="txtStart" CssClass="txtBox_generics"></asp:TextBox>
                                <asp:HiddenField ID="latlongStart" runat="server" Value="" />
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell></asp:TableCell>
                            <asp:TableCell>
                                <asp:Label ID="lblErrorLocalizationDep" ForeColor="Red" runat="server" meta:resourcekey="lblErrorLocalization"
                                    Visible="false"></asp:Label>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:Label ID="lblFinish" runat="server" meta:resourcekey="lblFinish" CssClass="lbl_strong"></asp:Label>
                            </asp:TableCell>
                            <asp:TableCell>
                                <asp:TextBox ID="txtFinish" runat="server" meta:resourcekey="txtFinish" CssClass="txtBox_generics"></asp:TextBox>
                                <asp:HiddenField ID="latlongFinish" runat="server" Value="" />
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell></asp:TableCell>
                            <asp:TableCell>
                                <asp:Label ID="lblErrorLocalizationArr" ForeColor="Red" runat="server" meta:resourcekey="lblErrorLocalization"
                                    Visible="false"></asp:Label>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:Label ID="lblDate" runat="server" meta:resourcekey="lblDate" CssClass="lbl_strong"></asp:Label>
                            </asp:TableCell>
                            <asp:TableCell>
                                <asp:TextBox ID="txtDate" runat="server" meta:resourcekey="txtDate" CssClass="txtBox_generics"></asp:TextBox>
                                <cc1:CalendarExtender ID="txtDate_CalendarExtender" runat="server" TargetControlID="txtDate"
                                    Enabled="true">
                                </cc1:CalendarExtender>
                                <!-- Data validator -->
                                <asp:RegularExpressionValidator ID="RegularExpressionValidatorData" runat="server"
                                    meta:resourcekey="RegularExpressionValidatorData" ControlToValidate="txtDate"
                                    ValidationExpression="(((0[1-9]|[12][0-9]|3[01])([/])(0[13578]|10|12)([/])(\d{4}))|(([0][1-9]|[12][0-9]|30)([/])(0[469]|11)([/])(\d{4}))|((0[1-9]|1[0-9]|2[0-8])([/])(02)([/])(\d{4}))|((29)(\.|-|\/)(02)([/])([02468][048]00))|((29)([/])(02)([/])([13579][26]00))|((29)([/])(02)([/])([0-9][0-9][0][48]))|((29)([/])(02)([/])([0-9][0-9][2468][048]))|((29)([/])(02)([/])([0-9][0-9][13579][26])))">
                                </asp:RegularExpressionValidator>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:Label ID="lblTollerance" runat="server" meta:resourcekey="lblTollerance" CssClass="lbl_strong"></asp:Label>
                            </asp:TableCell>
                            <asp:TableCell>
                                <asp:DropDownList ID="ddlTollerance" runat="server">
                                    <asp:ListItem Selected="True" Text=""></asp:ListItem>
                                    <asp:ListItem Text="1 Km"></asp:ListItem>
                                    <asp:ListItem Text="5 Km"></asp:ListItem>
                                    <asp:ListItem Text="10 Km"></asp:ListItem>
                                    <asp:ListItem Text="20 Km"></asp:ListItem>
                                    <asp:ListItem Text="50 Km"></asp:ListItem>
                                    <asp:ListItem Text="100 Km"></asp:ListItem>
                                </asp:DropDownList>
                            </asp:TableCell>
                        </asp:TableRow>
                    </asp:Table>
               <br />
            <asp:Button ID="btnSearch" runat="server" meta:resourcekey="btnSearch" CssClass="button_generics" OnClientClick="bindCoords()" OnClick="btnSearch_Click" />
            <asp:HyperLink ID="AllTrips" runat="server" NavigateUrl="~/travelSearch.aspx?Trips=All" >
                <asp:Label ID="lblAllTrips" runat="server" meta:resourcekey="lblAllTrips"></asp:Label>
            </asp:HyperLink>
           </div>
            </asp:Panel>
    </div>

    <script type="text/javascript">
        var arriveId = "<%=txtFinish.ClientID%>";
        var departureId = "<%=txtStart.ClientID%>";
        GUI.AAAGeoCodingMenu(document.getElementById(departureId), GUI.AAAGeoCodingMenu.RIGHT, GUI.AAAGeoCodingMenu.UP);
        GUI.AAAGeoCodingMenu(document.getElementById(arriveId));    
    </script>

</asp:Content>
